package aures.ui;

import org.gnome.gdk.Pixbuf;
import org.gnome.gtk.CellRendererText;
import org.gnome.gtk.DataColumn;
import org.gnome.gtk.DataColumnString;
import org.gnome.gtk.Image;
import org.gnome.gtk.ListStore;
import org.gnome.gtk.SortType;
import org.gnome.gtk.TextBuffer;
import org.gnome.gtk.TextTag;
import org.gnome.gtk.TextView;
import org.gnome.gtk.TreeIter;
import org.gnome.gtk.TreeView;
import org.gnome.gtk.TreeViewColumn;

public class AuresTable extends AuresPage {

	public AuresTable(String src, String root, String title) throws Exception {
		super(src, root, title);
		
		Pixbuf pix = new Pixbuf("/home/goundy/pix/poker/PublishSmall.png");
		Image i = (Image) this.getWidget("img");
		i.setImage(pix);
		
		
		TreeView tvusers = (TreeView)this.getWidget("TvUsers");
		TreeIter row;
		DataColumnString Users;
		CellRendererText renderer;
		TreeViewColumn vertical;
		
		ListStore model = new ListStore(new DataColumn[] {
				Users = new DataColumnString()
        });
		
		row = model.appendRow();
		model.setValue(row, Users, "Goundy");
		row = model.appendRow();
		model.setValue(row, Users, "Developpez");
		row = model.appendRow();
		model.setValue(row, Users, "Unknown");
		row = model.appendRow();
		model.setValue(row, Users, "Addict");
		row = model.appendRow();
		model.setValue(row, Users, "Tux");
		row = model.appendRow();
		model.setValue(row, Users, "Idler");
		
		tvusers.setModel(model);
		
		vertical = tvusers.appendColumn();
		vertical.setTitle("Users");
		renderer = new CellRendererText(vertical);
		renderer.setMarkup(Users);
		
		model.setSortColumn(Users, SortType.ASCENDING);
		
		// TextView
		
		TextBuffer buffer = new TextBuffer();
		
		TextView view = (TextView) this.getWidget("txtViewChat");

		view.setBuffer(buffer);
		
		TextTag grey = new TextTag();
		grey.setForeground("#777777");
		
		TextTag blue = new TextTag();
		blue.setForeground("blue");
		
		TextTag red = new TextTag();
		red.setForeground("red");
		
		buffer.insert(buffer.getIterEnd(), "<Goundy> I'm going to rox you !\n", red);
		buffer.insert(buffer.getIterEnd(), "<Idler> Please hurry up ! I wanna play :(\n", grey);
		buffer.insert(buffer.getIterEnd(), "<Tux> Tux or not tux ! that's the question\n", blue);
		buffer.insert(buffer.getIterEnd(), "<Goundy> Damn ! you're bluffing aren't you ?\n", red);
	}

}
